import request from '@/utils/request'
import { praseStrEmpty } from "@/utils/admin";

// 查询用户列表
export function listUser(query) {
  return request({
    url: '/user/system/sUser/page',
    method: 'post',
    data: query
  })
}

// 用户头像上传
export function uploadAvatar(data) {
  return request({
    url: '/user/system/sUser/avatar',
    method: 'post',
    data: data
  })
}


//查询部门
export function getDept(data) {
  return request({
    url: '/user/user/org/list',
    method: 'post',
    data: data
  })
}



//查询角色
export function listCanDoRole(query) {
  return request({
    url: '/user/system/sRole/findCurrentUserCandoRoles',
    method: 'get'
  })
}



// 新增用户
export function addUser(data) {
  return request({
    url: '/user/system/sUser/add',
    method: 'post',
    data: data
  })
}


export function resetMyPwd(data) {
  return request({
    url: '/user/system/sUser/resetMyPwd',
    method: 'post',
    data: data
  })
}

// 修改用户
export function updateUser(data) {
  return request({
    url: '/user/system/sUser/modify',
    method: 'post',
    data: data
  })
}

// 删除用户
export function delUser(userId) {
  return request({
    url: '/user/system/sUser/deleteFalse?id='+userId,
    method: 'get',
  })
}

export function findUser(userId) {
  if(typeof(userId) == "undefined"){
    return request({
      url: '/user/system/sUser/findUserById',
      method: 'get',
    })
  }else{
    return request({
      url: '/user/system/sUser/findUserById?userId='+userId,
      method: 'get',
    })
  }

}




//用户密码重置
export function resetUserPwd(userId, password) {
  const data = {
    userId,
    password
  }
  return request({
    url: '/user/system/sUser/modifyPwd',
    method: 'post',
    data: data
  })
}



//查询用户个人信息
export function getUserProfile() {
  return request({
    url: '/user/system/sUser/getUserInfo',
    method: 'get'
  })
}


//查询用户个人信息
export function listAlldept() {
  return request({
    url: '/user/system/sOrg/listDept',
    method: 'get'
  })
}
